package com.dongdongshop.service.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbUserScoreDetailMapper;
import com.dongdongshop.pojo.TbUserScoreDetail;
import com.dongdongshop.service.UserScoreDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Description
 * @ClassName UserScoreDetailServiceImpl
 * @Author RC
 * @date 2020.12.27 17:49
 */
@Component
@Service
public class UserScoreDetailServiceImpl implements UserScoreDetailService {
    @Autowired
    private TbUserScoreDetailMapper tbUserScoreDetailMapper;

    @Override
    public void insertInfo(String userId, int totalFee) {
        TbUserScoreDetail userScoreDetail = new TbUserScoreDetail();
        userScoreDetail.setUserId(userId);
        userScoreDetail.setPoint(totalFee);
        DateTime date = DateUtil.date(new Date());
        userScoreDetail.setCreateTime(date);
        DateTime date2 = DateUtil.nextMonth();
        userScoreDetail.setExpirTime(date2);
        userScoreDetail.setTextarea("增加积分");
        tbUserScoreDetailMapper.insertSelective(userScoreDetail);
    }

    @Override
    public void add(TbUserScoreDetail tb) {
        tbUserScoreDetailMapper.insertSelective(tb);
    }
}
